﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BOMS.Utility;

namespace BOMS.WebUI.Web.PowerControl
{
    public partial class PowerControlProcessAuto : System.Web.UI.Page
    {
        public int PowerControlID { get { return int.Parse(Request.Params["id"]); } }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Model.PowerControl aid = (new BLL.PowerControl()).GetModel(PowerControlID);

                if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                {
                    ShowInfo(PowerControlID);
                }
            }
        }
        private void ShowInfo(int ID)
        {
            BOMS.BLL.PowerControl bll = new BOMS.BLL.PowerControl();
            BOMS.Model.PowerControl model = bll.GetModel(ID);
            this.lblHostName.Text = model.HostName;
            this.lblPowerDownTime.Text = model.PowerDownTime.ToString();
            this.lblDealwithTime.Text = model.DealwithTime.ToString();
            this.lblResDscTime.Text = model.ResDscTime;
        }
        DataRow GetUserRow(string UserID)
        {
            DataRow dr = BOMS.DAL.SysAdmin.getUserInfoById(UserID).Rows[0];
            return dr;
        }
        protected void autoOpen_Save(object sender, EventArgs e)
        {
            BLL.PowerControl bll = new BLL.PowerControl();
            string IsPowerOnDealwith = "否";
            //是否让人来发电，这里默认为否，由于市电来了V=220才会弹出这个页面,点确认之后此更新为“否”才会进入停发电查询历史表
            bll.UpdatePowerOnDealWith(PowerControlID, IsPowerOnDealwith, DateTime.Now);
            //---------------V=220后，弹出页面的处理后更新数据库 --------by ln-----------
            Type cstype = this.GetType();
            ClientScript.RegisterStartupScript(cstype, "key", "dialogReturn('true');", true);
            ClientScript.RegisterStartupScript(cstype, "key", "dialogReturn('false');", true);
        }
    }
}